'use strict';

var _html = document.getElementsByTagName("html")[0];
_html.style.fontSize = document.documentElement.clientWidth / 750 * 100 + "px";
window.onresize = function(){
    _html.style.fontSize = document.documentElement.clientWidth / 750 * 100 + "px";
};

var URL;
var localUrl;

// URL = 'http://192.168.1.50:9091';

if((/(192\.168\.1\.)|(localhost)/).test(window.location.href)){
    URL = 'http://192.168.1.50:9091';
    //URL = 'http://192.168.1.216:9096';
}else{
    URL = 'https://appiwin.anjintech.com/'
    // localUrl = 'http://appiwin.anjintech.com/'
}

var vm = new Vue({
    el: '.wrap',
    data: {},
    mixins:typeof mixins != 'undefined' ? [mixins] : [],
    methods: {
        toast: function (msg) {
            if (!msg)return;
            $('#toast-message').remove();
            var str = $('<div id="toast-message">' + msg + '</div>');
            str.appendTo($('body'));
            str.stop().fadeOut(3000);
        },
        requestFun: function (url,params) {
            var _this=this
            _this.loading=false
            var _params = '';
            params && (_params = '?encryptData=' + encodeURIComponent(JSON.stringify({
                data: params
            })));
            var _url = url + _params;
            var deferred = $.Deferred();
            $.post(_url, '', function(data) {
                _this.loading=false
                deferred.resolve(data.data);
            }, 'json');

            return deferred.promise();
        },
        href: function(link,params){
            if(link){
                var p = '';
                if(params){
                    p = '?';
                    for(var i in params){
                        if(p != '?')p += '&';
                        p += i + '=' + params[i];
                    }
                }
                window.location.href = link + p;
            }
        },
        changeTitle: function (title) {
            var $body = $('body');
            document.title = title;
            var $iframe = $('<iframe src="//m.baidu.com/favicon.ico"></iframe>').on('load', function () {
                setTimeout(function () {
                    $iframe.off('load').remove()
                }, 0)
            }).appendTo($body);
        },
        searchKey: function(key){
            var reg = new RegExp(key + '=[^&]+');
            var url = decodeURI(window.location.href);
            if((reg).test(url)){
                return url.match(reg)[0].split('=')[1];
            }
        },
    },
    computed: {

    },
    // created: typeof created != 'undefined' ? created : null
});